package zee.com.customviewexample.activity;

import android.media.MediaPlayer;
import android.view.View;
import android.widget.ImageView;
import android.widget.SeekBar;

import com.zee.listener.VideoPlayViewListener;
import com.zee.view.VideoPlayView;

import zee.com.customviewexample.R;

/**
 * 视频播放
 */
public class VideoPlayViewActivity extends BaseActivity {
    @Override
    public int getLayoutID() {
        return R.layout.activity_video_play_view;
    }

    @Override
    public void initViews() {
        VideoPlayView textureView = findViewById(R.id.textureview);

        final ImageView videoImage = findViewById(R.id.video_image);

        final SeekBar seekBar = findViewById(R.id.seekbar);
        //为seekbar设置监听
        textureView.setVideoPlayViewListener(new VideoPlayViewListener() {
            @Override
            public void onProgress(int value, int max) {
                seekBar.setMax(max);
                seekBar.setProgress(value);
            }

            @Override
            public void onCompletion(MediaPlayer mp) {
                videoImage.setVisibility(View.VISIBLE);
            }

            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.start();
                videoImage.setVisibility(View.GONE);
            }
        });
    }
}
